<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>子组件与父组件</title>
    <script src="js/vue.js"></script>

</head>

<body>
    <div id="app">
        <my-hello></my-hello>
    </div>

    <template id='hello'>
        <div>
            <h3>我是Hello父组件</h3>
            <h3>访问自己的数据 {{msg}},{{name}},{{age}},{{user.username}}</h3>
            <hr>
            <my-world :msg = 'msg' :name='name' :age='age' :user='user'></my-world>
        </div>
    </template>

    <template id='world'>
        <div>
            <h3>我是World子组件</h3>
            <h3>访问父组件的数据: {{msg}},{{name}},{{age}},{{user.username}}</h3>
        </div>
    </template>

    <script>
        var vm = new Vue({
            el: '#app',
            components: {
                'my-hello': {
                    data() {
                        return {
                            msg: 'Hello',
                            name: 'tom',
                            age: 22,
                            user: { id: 11, username: "tang" }
                        }
                    },
                    template: '#hello',
                    components: {
                        'my-world': {
                            data(){
                                return{
                                    sex:
                                }
                            },
                            template: '#world',
                            props:['msg','name','age','user']
                        }
                    }
                }
            }
        })
    </script>
</body>

</html>